.class public final Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;
.super Ljava/lang/Object;
.source "VideoTracker.java"


# static fields
.field private static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final SLEEP_DELAY:I = 0x3e8

.field private static final TAG:Ljava/lang/String; = "VideoTracker"


# instance fields
.field volatile mCancelled:Z

.field final mMiddleTrackUrl:[Ljava/lang/String;

.field volatile mPaused:Z

.field final mPlayer:Landroid/widget/VideoView;

.field private mTracker:Ljava/lang/Runnable;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 36
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->LOG:Lcom/burstly/lib/util/LoggerExt;

    return-void
.end method

.method constructor <init>(Landroid/widget/VideoView;[Ljava/lang/String;)V
    .locals 4
    .parameter "videoView"
    .parameter "middleTrackUrl"

    .prologue
    .line 79
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 80
    iput-object p1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mPlayer:Landroid/widget/VideoView;

    .line 81
    iput-object p2, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mMiddleTrackUrl:[Ljava/lang/String;

    .line 82
    if-eqz p2, :cond_0

    array-length v0, p2

    if-lez v0, :cond_0

    .line 83
    invoke-direct {p0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->createTrackerRunnable()Ljava/lang/Runnable;

    move-result-object v0

    iput-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mTracker:Ljava/lang/Runnable;

    .line 87
    :goto_0
    return-void

    .line 85
    :cond_0
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "VideoTracker"

    const-string v2, "Track video middle request will not be sent because of the url is null."

    const/4 v3, 0x0

    new-array v3, v3, [Ljava/lang/Object;

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_0
.end method

.method static synthetic access$000()Lcom/burstly/lib/util/LoggerExt;
    .locals 1

    .prologue
    .line 31
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->LOG:Lcom/burstly/lib/util/LoggerExt;

    return-object v0
.end method

.method private createTrackerRunnable()Ljava/lang/Runnable;
    .locals 1

    .prologue
    .line 95
    new-instance v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker$1;

    invoke-direct {v0, p0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker$1;-><init>(Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;)V

    return-object v0
.end method

.method private static sendRequest(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
    .locals 3
    .parameter "requestVideoUrl"
    .parameter "requestId"
    .parameter "failMessage"

    .prologue
    .line 241
    if-eqz p0, :cond_0

    .line 242
    invoke-static {p0, p1}, Lcom/burstly/lib/network/request/RequestManager;->makeTrackEventRequest(Ljava/lang/String;Ljava/lang/String;)Lcom/burstly/lib/network/request/AbortableAsyncTask;

    .line 246
    :goto_0
    return-void

    .line 244
    :cond_0
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "VideoTracker"

    const/4 v2, 0x0

    new-array v2, v2, [Ljava/lang/Object;

    invoke-virtual {v0, v1, p2, v2}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_0
.end method

.method private setPaused(Z)V
    .locals 4
    .parameter "isPaused"

    .prologue
    .line 201
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mTracker:Ljava/lang/Runnable;

    if-eqz v0, :cond_0

    .line 202
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "VideoTracker"

    if-eqz p1, :cond_1

    const-string v0, "Pause video watch thread."

    :goto_0
    const/4 v3, 0x0

    new-array v3, v3, [Ljava/lang/Object;

    invoke-virtual {v1, v2, v0, v3}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 204
    :cond_0
    iput-boolean p1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mPaused:Z

    .line 205
    return-void

    .line 202
    :cond_1
    const-string v0, "Unpause video watch thread."

    goto :goto_0
.end method

.method static sleep(I)V
    .locals 2
    .parameter "interval"

    .prologue
    .line 162
    int-to-long v0, p0

    :try_start_0
    invoke-static {v0, v1}, Ljava/lang/Thread;->sleep(J)V
    :try_end_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0

    .line 167
    :goto_0
    return-void

    .line 164
    :catch_0
    move-exception v0

    goto :goto_0
.end method

.method static trackVideoEnd([Ljava/lang/String;)V
    .locals 7
    .parameter "endVideoUrl"

    .prologue
    .line 227
    const-string v3, "VideoTracker TrackEnd"

    .line 228
    .local v3, requestId:Ljava/lang/String;
    move-object v0, p0

    .local v0, arr$:[Ljava/lang/String;
    array-length v2, v0

    .local v2, len$:I
    const/4 v1, 0x0

    .local v1, i$:I
    :goto_0
    if-ge v1, v2, :cond_0

    aget-object v4, v0, v1

    .line 229
    .local v4, url:Ljava/lang/String;
    const-string v5, "VideoTracker TrackEnd"

    const-string v6, "Can not send watch-to-the-end track request because of urls are null"

    invoke-static {v4, v5, v6}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->sendRequest(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 228
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .line 231
    .end local v4           #url:Ljava/lang/String;
    :cond_0
    return-void
.end method


# virtual methods
.method cancel()V
    .locals 5

    .prologue
    const/4 v4, 0x1

    .line 211
    iget-boolean v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mCancelled:Z

    if-nez v0, :cond_1

    .line 212
    invoke-direct {p0, v4}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->setPaused(Z)V

    .line 213
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mTracker:Ljava/lang/Runnable;

    if-eqz v0, :cond_0

    .line 214
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "VideoTracker"

    const-string v2, "Cancel video watch thread."

    const/4 v3, 0x0

    new-array v3, v3, [Ljava/lang/Object;

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 215
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mTracker:Ljava/lang/Runnable;

    .line 217
    :cond_0
    iput-boolean v4, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mCancelled:Z

    .line 219
    :cond_1
    return-void
.end method

.method pause()V
    .locals 1

    .prologue
    .line 185
    const/4 v0, 0x1

    invoke-direct {p0, v0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->setPaused(Z)V

    .line 186
    return-void
.end method

.method resume()V
    .locals 1

    .prologue
    .line 192
    const/4 v0, 0x0

    invoke-direct {p0, v0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->setPaused(Z)V

    .line 193
    return-void
.end method

.method startMiddlepointTracking()V
    .locals 5

    .prologue
    .line 173
    iget-object v1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mTracker:Ljava/lang/Runnable;

    if-eqz v1, :cond_0

    .line 174
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "VideoTracker"

    const-string v3, "Started middle point tracker..."

    const/4 v4, 0x0

    new-array v4, v4, [Ljava/lang/Object;

    invoke-virtual {v1, v2, v3, v4}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 175
    new-instance v0, Ljava/lang/Thread;

    iget-object v1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mTracker:Ljava/lang/Runnable;

    invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    .line 176
    .local v0, thread:Ljava/lang/Thread;
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    iget-object v2, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoTracker;->mMiddleTrackUrl:[Ljava/lang/String;

    invoke-static {v2}, Ljava/util/Arrays;->toString([Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, " tracker"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/Thread;->setName(Ljava/lang/String;)V

    .line 177
    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    .line 179
    .end local v0           #thread:Ljava/lang/Thread;
    :cond_0
    return-void
.end method
